package com.dealer.management.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dealer.management.entity.Supplier;
import com.dealer.management.mapper.SupplierMapper;
import com.dealer.management.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public IPage<Supplier> getSupplierPage(Page<Supplier> page, String name) {
        return supplierMapper.selectSupplierPage(page, name);
    }

    @Override
    public Supplier getSupplierById(Long id) {
        return supplierMapper.selectById(id);
    }

    @Override
    public boolean saveSupplier(Supplier supplier) {
        return supplierMapper.insert(supplier) > 0;
    }

    @Override
    public boolean updateSupplier(Supplier supplier) {
        return supplierMapper.updateById(supplier) > 0;
    }

    @Override
    public boolean deleteSupplier(Long id) {
        return supplierMapper.deleteById(id) > 0;
    }
}
